package com.paradise.ytj.utils;

import android.app.Activity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/12/10 0010.
 */

public class ActivityUtils {
    private static List<Activity> oList = new ArrayList<>();

    /**
     * 添加Activity
     */
    public static  void addActivity(Activity activity) {
        if (oList == null) {
            oList = new ArrayList<>();
        }
        if (!oList.contains(activity)) {
            oList.add(activity);
        }
    }

    /**
     * 销毁单个Activity
     */
    public static void removeActivity(Activity activity) {
        if (oList == null) {
            oList = new ArrayList<>();
        }
        if (oList.contains(activity)) {
            oList.remove(activity);
            activity.finish();
        }
    }

    /**
     * 销毁所有的Activity
     */
    public static void removeALLActivity() {
        if (oList == null) {
            oList = new ArrayList<>();
        }
        for (Activity activity : oList) {
            activity.finish();
        }
    }
}
